﻿@using PlatformNetCore.Entity
@{
    ViewBag.Title = "编辑角色";
}
<style>
    html {
        background-color: #fff;
    }

    .layui-card {
        box-shadow: none;
    }
</style>
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="@Url.Action("RoleEdit","Sys",new { area = "Admin"})" lay-filter="roleedit-form">
            <div class="layui-form-item">
                <label class="layui-form-label">角色编号</label>
                <div class="layui-input-block">
                    <input type="hidden" name="ID" lay-verify="required" autocomplete="on" class="layui-input">
                    <span id="spanID"></span>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">角色名称</label>
                <div class="layui-input-block">
                    <input type="text" name="RoleName" lay-verify="required" placeholder="请输入角色名称" autocomplete="on" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">上级角色</label>
                <div class="layui-input-block">
                    <select name="ParentID" lay-filter="ParentID">
                        @foreach (var item in (IEnumerable<SelectListItem>)ViewBag.ParentRoleDLL)
                        {
                            <option value="@item.Value">@item.Text</option>
                        }
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">排序号</label>
                <div class="layui-input-block">
                    <input type="text" name="SortNo" value="1000" lay-verify="required" placeholder="排序号" autocomplete="on" class="layui-input">
                </div>
            </div>
            <div id="roleedit-submit" lay-submit lay-filter="roleedit-submit"></div>
        </form>
    </div>
</div>
<script>
    layui.use(['form'], function () {
        var $ = layui.$, form = layui.form;

        form.render(null, 'roleedit-form');

        //从父层获取值，json是父层的全局js变量。eval是将该string类型的json串变为标准的json串
        var editObj = parent.editData;
        $("#spanID").html(editObj.ID);
        //表单初始赋值
        form.val('roleedit-form', {
            "ID": editObj.ID
            , "RoleName": editObj.RoleName
            , "ParentID": editObj.ParentID
            , "SortNo": editObj.SortNo
        })

    });
</script>
